﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ChangeFlight.aspx.cs" Inherits="ChangeFlight" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
 
    <script type="text/javascript">
        function addFile() {
            var _table = document.createElement("table");
            var _tbody = document.createElement("TBODY");
            var _row;
            var _cell;
            var rlen = parseInt(document.getElementById("rowlen").value);
            for (var i = 0; i < rlen; i++) {
                _row = document.createElement("tr");
                for (var j = 0; j < 3; j++) {
                    _cell = document.createElement("td");
                    var div = document.createElement("div");
                    var f = document.createElement("input");
                    f.setAttribute("type", "text")
                    f.setAttribute("name", "txtCardNo")
                    f.setAttribute("size", "20")
                    div.appendChild(f)
                    var d = document.createElement("input");
                    d.setAttribute("type", "button")
                    d.setAttribute("onclick", "deteFile(this)");
                    d.setAttribute("value", "移除")
                    div.appendChild(d)
                    _cell.appendChild(div);
                    _row.appendChild(_cell);
                }
                _tbody.appendChild(_row);
            }
            _table.appendChild(_tbody);
            var con = document.getElementById("_container");
            con.innerHTML = "";
            con.appendChild(_table);
        }

        function deteFile(o) {
            while (o.tagName != "DIV") o = o.parentNode;
            o.parentNode.removeChild(o);
        }

        function getAllTd() {
            document.getElementsByTagName("td")[0].style.backgroundImage = 'url(http://img.baidu.com/img/logo-zhidao.gif)';
        }
    </script>
 
</head>
<body>
    <form id="form1" runat="server">
    <select id="rowlen">
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
    </select>
    <input value="add" type="button" onclick="addFile()" />
    <div id="_container">
    </div>
    <input type="button" value="ok" onclick="getAllTd()" />
    </form>
</body>
</html>